<?php
/**
 * Created by PhpStorm.
 * User: Soha_Ros
 * Date: 17/6/2
 * Time: 上午1:16
 */

namespace ActionsHttp;

use Data\Food_tags_DAO;

class RestaurantFoodTagsUpdate extends BaseActionHttp
{
    public function doAction() {

        parent::doAction();

        // 商铺id
        $restaurant_id = $_SESSION[RESTAURANT_ID];
        $restaurant_id = 1;

        $tags_id = $this->data[FOOD_TAG_ID];

        // 名称
        $name = $this->data[FOOD_TAG_NAME];
        // 颜色
        $color = $this->data[FOOD_TAG_COLOR];

        $tag_record = Food_tags_DAO::getRecord($tags_id);

        if (!$tag_record) {
            return $this->SendErrMsg("没有该标签");
        }

        if ($tag_record->getRESTAURANT_ID() != $restaurant_id) {
            return $this->SendErrMsg("非法操作");
        }


        $tag_record->setFOOD_TAG_NAME($name);
        $tag_record->setFOOD_TAG_COLOR($color);

        // 插入数据库
        Food_tags_DAO::update($tag_record);

        // 返回数据
        $this->ResponseDataToCurrentClient();

    }
}